package main.java.easy;

import main.java.structure.ListNode;

/**
 * @Author: 郑国荣
 * @Date: 2023-07-24-0:54
 * @Description:
 */
public class DeleteDuplicates {
    public static void deleteDuplicates(ListNode head) {
        ListNode current = head;
        while (current != null && current.next != null){
            if (current.val == current.next.val){
                current.next = current.next.next;
            }else {
                current = current.next;
            }
        }
    }

    public static void main(String[] args) {
        ListNode listNode = new ListNode(1);
        ListNode listNode2 = new ListNode(1);
        ListNode listNode3 = new ListNode(2);
        ListNode listNode4 = new ListNode(2);
        listNode.next = listNode2;
        listNode2.next = listNode3;
        listNode3.next = listNode4;
        deleteDuplicates(listNode);
        while (listNode!=null){
            System.out.println(listNode.val);
            listNode = listNode.next;
        }
    }
}
